<?php
    header('content-type:text/html;charset=utf-8;');
    $link = mysqli_connect('127.0.0.1','root','root','jd');
    $name = $_POST['un'];
    $pw = $_POST['pw'];
    
    $sql = "SELECT * FROM `userinfo` WHERE `username`='$name' AND `password`='$pw'";
    $res = mysqli_query($link,$sql);
    $arr = mysqli_fetch_assoc($res);
    if($arr){
        echo '{"code":1}';
        setcookie('name',$name,7*24*60*60+time());
    }else{
        echo '{"code":0}';
    }
?>